package com.myoffice.action;

import org.apache.struts2.convention.annotation.Action;
import org.springframework.beans.factory.annotation.Autowired;

import com.myoffice.biz.RepairBiz;
import com.myoffice.pageModel.base.Json;

/**
 * 修复数据库ACTION
 * 
 * @author jie
 * 
 */
@Action(value = "repairAction")
public class RepairAction extends BaseAction {

	private RepairBiz repairBiz;


	public RepairBiz getRepairBiz() {
		return repairBiz;
	}
	@Autowired
	public void setRepairBiz(RepairBiz repairBiz) {
		this.repairBiz = repairBiz;
	}

	/**
	 * 修复数据库
	 * 
	 * @return
	 */
	@SuppressWarnings("finally")
	public String doNotNeedSession_repairAction() {
		Json j=new Json();
		try {
			repairBiz.repair();
			
			j.setMsg("修复成功！");
			j.setSuccess(true);
		} catch (Exception e) {
			j.setMsg("修复成功！");
			j.setSuccess(true);
		}finally{
			super.writeJson(j);
			return "success";			
		}
	}

	/**
	 * 先清空数据库，然后再修复数据库
	 * 
	 * @return
	 */
	public String doNotNeedSession_deleteAndRepair() {
		try {
			repairBiz.deleteAndRepair();
			return "success";
		} catch (Exception e) {
			return "input";
		}
	}
}
